home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / array / stringcopy.c < prev    next >
C/C++ Source or Header  |  2001-05-12  |  530b  |  34 lines

  1.  
  2. #include "tek/array.h"
  3.  
  4. /* 
  5. **    TEKlib
  6. **    (C) 2001 TEK neoscientists
  7. **    all rights reserved.
  8. **
  9. **    TBOOL TStringCopy(TSTRPTR *s1, TSTRPTR s2)
  10. **
  11. **    copy dynamic string to another dynamic string.
  12. **
  13. */
  14.  
  15. TBOOL TStringCopy(TSTRPTR *s1, TSTRPTR s2)
  16. {
  17.     if (*s1 && s2)
  18.     {
  19.         TARRAY *a1 = *((TARRAY **) s1) - 1;
  20.         TARRAY *a2 = ((TARRAY *) s2) - 1;
  21.     
  22.         if (a1->valid && a2->valid)
  23.         {
  24.             TUINT newlen = a2->len;
  25.             if (TArraySetLen((TAPTR *) s1, newlen))
  26.             {
  27.                 TMemCopy(s2, *s1, newlen);
  28.                 return TTRUE;
  29.             }
  30.         }
  31.     }
  32.     return TFALSE;
  33. }
  34.